package cn.com.headfree.base.service;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;



/**
 * Title: Description:统一权限平台接口调用 Copyright: Copyright (c) 2017 Company:
 * www.headfree.com.cn
 * 
 * @author fengya
 * @version 1.0
 * @date 2019年8月9日 下午2:55:08
 */
@Component
public class IscSsoCall {

	private static String isoUrl;

	@Value("${isc.sso.url}")
	public void setAPPID(String isoUrl) {
		IscSsoCall.isoUrl = isoUrl;
	}
	
	/***
	 * @description 请求统一权限平台接口调用
	 * @author 冯亚
	 * @date 2019年10月23日 下午6:40:19
	 * @param url
	 * @return
	 * @throws Exception
	 * String
	 */
	public static String appInfoApi(String url) throws Exception {
		GetMethod get = new GetMethod(IscSsoCall.isoUrl + "/v1/api" + url);
		get.setRequestHeader("charset", "utf-8");
		new HttpClient().executeMethod(get);
		return get.getResponseBodyAsString();
	}
	
	/**
	 * @param url
	 * @return
	 * @throws Exception
	 */
	public static String iscPostApi(String url) throws Exception {
		PostMethod post = new PostMethod(IscSsoCall.isoUrl + "/v1/api" + url);
		post.setRequestHeader("charset", "utf-8");
		new HttpClient().executeMethod(post);
		return post.getResponseBodyAsString();
	}
	
	
}
